/*
 Navicat Premium Dump SQL

 Source Server         : @localhost
 Source Server Type    : MySQL
 Source Server Version : 80041 (8.0.41)
 Source Host           : localhost:3306
 Source Schema         : logistics_saas

 Target Server Type    : MySQL
 Target Server Version : 80041 (8.0.41)
 File Encoding         : 65001

 Date: 15/11/2025 23:08:01
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for customer
-- ----------------------------
DROP TABLE IF EXISTS `customer`;
CREATE TABLE `customer` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `customer_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户编号',
  `customer_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户名称',
  `customer_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户类型（ENTERPRISE/PERSONAL）',
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '联系人',
  `contact_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '联系电话',
  `settlement_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '结算方式（MONTHLY/PREPAID/COLLECT）',
  `credit_limit` decimal(10,2) DEFAULT NULL COMMENT '信用额度',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '合作状态（1正常 0暂停）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_customerno` (`tenant_id`,`customer_no`),
  KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户表';

-- ----------------------------
-- Records of customer
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for dispatch_record
-- ----------------------------
DROP TABLE IF EXISTS `dispatch_record`;
CREATE TABLE `dispatch_record` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `site_id` bigint DEFAULT NULL COMMENT '站点ID',
  `vehicle_id` bigint NOT NULL COMMENT '车辆ID',
  `vehicle_plate` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车牌号',
  `vehicle_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车辆类型',
  `driver_id` bigint DEFAULT NULL COMMENT '司机ID（可为空，临时车辆可能没有固定司机）',
  `driver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '司机姓名',
  `driver_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '司机电话',
  `destination` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '目的地',
  `order_count` int DEFAULT '0' COMMENT '装载订单数量',
  `scheduled_departure_time` datetime DEFAULT NULL COMMENT '计划发车时间',
  `actual_departure_time` datetime DEFAULT NULL COMMENT '实际发车时间',
  `estimated_arrival_time` datetime DEFAULT NULL COMMENT '预计到达时间',
  `actual_arrival_time` datetime DEFAULT NULL COMMENT '实际到达时间',
  `dispatch_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'READY' COMMENT '发车状态：READY-待发车，DISPATCHED-已发车，ARRIVED-已到达，CANCELLED-已取消',
  `route_info` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '路线信息JSON',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `cancel_reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '取消原因',
  `cancel_time` datetime DEFAULT NULL COMMENT '取消时间',
  `cancel_by` bigint DEFAULT NULL COMMENT '取消人ID',
  `dispatch_confirm_by` bigint DEFAULT NULL COMMENT '发车确认人ID',
  `arrival_confirm_by` bigint DEFAULT NULL COMMENT '到达确认人ID',
  `create_by` bigint DEFAULT NULL COMMENT '创建人ID',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新人ID',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_site_id` (`site_id`),
  KEY `idx_vehicle_id` (`vehicle_id`),
  KEY `idx_driver_id` (`driver_id`),
  KEY `idx_dispatch_status` (`dispatch_status`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='发车记录表';

-- ----------------------------
-- Records of dispatch_record
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for driver
-- ----------------------------
DROP TABLE IF EXISTS `driver`;
CREATE TABLE `driver` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `site_id` bigint NOT NULL COMMENT '站点ID',
  `driver_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '工号',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '姓名',
  `gender` tinyint DEFAULT NULL COMMENT '性别（1男 2女）',
  `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '联系电话',
  `id_card` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '身份证号',
  `license_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '驾驶证类型（C1/C2/B1/B2/A1/A2/A3）',
  `license_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '驾驶证号',
  `license_expire_date` date NOT NULL COMMENT '驾驶证到期日期',
  `entry_date` date NOT NULL COMMENT '入职日期',
  `emergency_contact` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急联系人',
  `emergency_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '紧急联系电话',
  `driver_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '状态（IDLE/BUSY/VACATION/RESIGNED）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_driverno` (`tenant_id`,`driver_no`),
  UNIQUE KEY `uk_tenant_phone` (`tenant_id`,`phone`),
  UNIQUE KEY `uk_tenant_idcard` (`tenant_id`,`id_card`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_driver_status` (`tenant_id`,`driver_status`),
  KEY `idx_site` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='司机表';

-- ----------------------------
-- Records of driver
-- ----------------------------
BEGIN;
INSERT INTO `driver` (`id`, `tenant_id`, `site_id`, `driver_no`, `name`, `gender`, `phone`, `id_card`, `license_type`, `license_no`, `license_expire_date`, `entry_date`, `emergency_contact`, `emergency_phone`, `driver_status`, `remark`, `create_time`, `update_time`) VALUES (1, 1, 1, 'SZ001-SJ000001', '王大明', 1, '13700001001', '440300199001011111', 'C1', 'C1D1234567890123456', '2028-01-15', '2020-03-01', '王小红', '13700001002', 'IDLE', '经验丰富', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `driver` (`id`, `tenant_id`, `site_id`, `driver_no`, `name`, `gender`, `phone`, `id_card`, `license_type`, `license_no`, `license_expire_date`, `entry_date`, `emergency_contact`, `emergency_phone`, `driver_status`, `remark`, `create_time`, `update_time`) VALUES (2, 1, 2, 'SZ002-SJ000001', '李小强', 1, '13700001003', '440300199002022222', 'B2', 'B2E2345678901234567', '2027-06-20', '2019-05-15', '李美丽', '13700001004', 'IDLE', '驾驶技术好', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `driver` (`id`, `tenant_id`, `site_id`, `driver_no`, `name`, `gender`, `phone`, `id_card`, `license_type`, `license_no`, `license_expire_date`, `entry_date`, `emergency_contact`, `emergency_phone`, `driver_status`, `remark`, `create_time`, `update_time`) VALUES (3, 2, 3, 'SH001-SJ000001', '张伟', 1, '13700002001', '310115199004044444', 'C1', 'C1G4567890123456789', '2027-08-30', '2018-06-10', '张丽', '13700002002', 'IDLE', '本地路况熟悉', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `driver` (`id`, `tenant_id`, `site_id`, `driver_no`, `name`, `gender`, `phone`, `id_card`, `license_type`, `license_no`, `license_expire_date`, `entry_date`, `emergency_contact`, `emergency_phone`, `driver_status`, `remark`, `create_time`, `update_time`) VALUES (4, 2, 4, 'SH002-SJ000001', '赵磊', 1, '13700002003', '310115199005055555', 'B2', 'B2H5678901234567890', '2028-03-15', '2020-09-01', '赵芳', '13700002004', 'IDLE', '货运经验丰富', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
COMMIT;

-- ----------------------------
-- Table structure for platform_tenant
-- ----------------------------
DROP TABLE IF EXISTS `platform_tenant`;
CREATE TABLE `platform_tenant` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户编码（唯一，如T000001）',
  `company_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '企业名称',
  `credit_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '统一社会信用代码',
  `contact_person` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '联系人',
  `contact_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '联系电话',
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '企业邮箱',
  `company_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '企业地址',
  `subdomain` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '自定义二级域名',
  `subscription_plan` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订阅套餐（BASIC/PRO/ENTERPRISE）',
  `subscription_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订阅状态（TRIAL/NORMAL/EXPIRED/DISABLED）',
  `expire_time` datetime NOT NULL COMMENT '到期时间',
  `trial_days` int DEFAULT '0' COMMENT '试用天数',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态（1启用 0停用）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_code` (`tenant_code`),
  UNIQUE KEY `uk_subdomain` (`subdomain`),
  KEY `idx_subscription_status` (`subscription_status`),
  KEY `idx_expire_time` (`expire_time`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='平台租户表';

-- ----------------------------
-- Records of platform_tenant
-- ----------------------------
BEGIN;
INSERT INTO `platform_tenant` (`id`, `tenant_code`, `company_name`, `credit_code`, `contact_person`, `contact_phone`, `email`, `company_address`, `subdomain`, `subscription_plan`, `subscription_status`, `expire_time`, `trial_days`, `status`, `create_time`, `update_time`) VALUES (1, 'T000001', '顺丰速运有限公司', '91440300708461136T', '王经理', '13800138001', 'admin@sf-express.com', '深圳市南山区科技园', 'sfexpress', 'ENTERPRISE', 'NORMAL', '2026-11-14 15:00:00', 15, 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `platform_tenant` (`id`, `tenant_code`, `company_name`, `credit_code`, `contact_person`, `contact_phone`, `email`, `company_address`, `subdomain`, `subscription_plan`, `subscription_status`, `expire_time`, `trial_days`, `status`, `create_time`, `update_time`) VALUES (2, 'T000002', '圆通速递有限公司', '91310115553281203G', '张总监', '13800138002', 'admin@yto.net.cn', '上海市嘉定区华亭镇', 'yuantong', 'PRO', 'NORMAL', '2026-06-14 15:00:00', 0, 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
COMMIT;

-- ----------------------------
-- Table structure for subscription_order
-- ----------------------------
DROP TABLE IF EXISTS `subscription_order`;
CREATE TABLE `subscription_order` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `order_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单号（唯一）',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `plan_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '套餐类型（BASIC/PRO/ENTERPRISE）',
  `order_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单类型（NEW/RENEW/UPGRADE）',
  `order_amount` decimal(10,2) NOT NULL COMMENT '订单金额',
  `payment_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付方式（ALIPAY/WECHAT/TRANSFER）',
  `payment_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付状态（PENDING/PAID/CANCELLED/REFUNDED）',
  `payment_time` datetime DEFAULT NULL COMMENT '支付时间',
  `payment_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付流水号',
  `start_time` datetime NOT NULL COMMENT '服务开始时间',
  `end_time` datetime NOT NULL COMMENT '服务结束时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_order_no` (`order_no`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_payment_status` (`payment_status`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订阅订单表';

-- ----------------------------
-- Records of subscription_order
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `sys_dictionary`;
CREATE TABLE `sys_dictionary` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID（0表示系统预置，所有租户可见）',
  `dict_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典类型（PAYMENT_METHOD/VEHICLE_TYPE/VEHICLE_STATUS/DRIVER_STATUS）',
  `dict_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典代码（PICKUP_PAY/VAN/IDLE等）',
  `dict_label` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '字典标签（提付/厢式货车/空闲等）',
  `dict_value` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '字典值（扩展用）',
  `sort_order` int DEFAULT '0' COMMENT '排序',
  `status` tinyint DEFAULT '1' COMMENT '状态（1启用 0停用）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `is_system` tinyint DEFAULT '0' COMMENT '是否系统预置（1是 0否，系统预置不可删除）',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_type_code` (`tenant_id`,`dict_type`,`dict_code`),
  KEY `idx_tenant_type` (`tenant_id`,`dict_type`),
  KEY `idx_dict_type` (`dict_type`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='系统字典表';

-- ----------------------------
-- Records of sys_dictionary
-- ----------------------------
BEGIN;
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (1, 0, 'PAYMENT_METHOD', 'PREPAID', '预付', NULL, 1, 1, '预付款（发货方付款）', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (2, 0, 'PAYMENT_METHOD', 'COLLECT', '到付', NULL, 2, 1, '到付款（收货方付款）', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (3, 0, 'PAYMENT_METHOD', 'PICKUP_PAY', '提付', NULL, 3, 1, '提货付款', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (4, 0, 'VEHICLE_TYPE', 'VAN', '厢式货车', NULL, 1, 1, '封闭式厢体货车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (5, 0, 'VEHICLE_TYPE', 'FLATBED', '平板车', NULL, 2, 1, '平板式货车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (6, 0, 'VEHICLE_TYPE', 'REFRIGERATED', '冷藏车', NULL, 3, 1, '冷链运输车辆', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (7, 0, 'VEHICLE_TYPE', 'TRUCK', '货车', NULL, 4, 1, '普通货车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (8, 0, 'VEHICLE_TYPE', 'OTHER', '其他', NULL, 5, 1, '其他类型车辆', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (9, 0, 'VEHICLE_STATUS', 'AVAILABLE', '可用', NULL, 1, 1, '车辆可正常使用', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (10, 0, 'VEHICLE_STATUS', 'IN_USE', '使用中', NULL, 2, 1, '车辆正在执行任务', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (11, 0, 'VEHICLE_STATUS', 'MAINTENANCE', '维修中', NULL, 3, 1, '车辆正在维修保养', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (12, 0, 'VEHICLE_STATUS', 'DISABLED', '停用', NULL, 4, 1, '车辆已停用', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (13, 0, 'DRIVER_STATUS', 'IDLE', '空闲', NULL, 1, 1, '司机空闲状态', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (14, 0, 'DRIVER_STATUS', 'BUSY', '忙碌', NULL, 2, 1, '司机工作中', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (15, 0, 'DRIVER_STATUS', 'VACATION', '休假', NULL, 3, 1, '司机休假中', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (16, 0, 'DRIVER_STATUS', 'RESIGNED', '离职', NULL, 4, 1, '司机已离职', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (17, 0, 'ORDER_STATUS', 'RECEIVED', '已收货', NULL, 1, 1, '货物已收货开票', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (18, 0, 'ORDER_STATUS', 'LOADED', '已装车', NULL, 2, 1, '货物已装车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (19, 0, 'ORDER_STATUS', 'IN_TRANSIT', '运输中', NULL, 3, 1, '货物运输中', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (20, 0, 'ORDER_STATUS', 'ARRIVED', '已到货', NULL, 4, 1, '货物已到达目的地', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (21, 0, 'ORDER_STATUS', 'DELIVERING', '派送中', NULL, 5, 1, '货物派送中', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (22, 0, 'ORDER_STATUS', 'COMPLETED', '已完成', NULL, 6, 1, '订单已完成', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (23, 0, 'ORDER_STATUS', 'CANCELLED', '已取消', NULL, 7, 1, '订单已取消', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (24, 0, 'DISPATCH_STATUS', 'READY', '待发车', NULL, 1, 1, '等待发车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (25, 0, 'DISPATCH_STATUS', 'DISPATCHED', '已发车', NULL, 2, 1, '车辆已发车', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (26, 0, 'DISPATCH_STATUS', 'ARRIVED', '已到达', NULL, 3, 1, '车辆已到达', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (27, 0, 'DISPATCH_STATUS', 'CANCELLED', '已取消', NULL, 4, 1, '发车已取消', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (28, 0, 'DELIVERY_TYPE', 'DELIVERY', '送货上门', NULL, 1, 1, '送货上门服务', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (29, 0, 'DELIVERY_TYPE', 'PICKUP', '到站自提', NULL, 2, 1, '客户到站点自提', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (30, 0, 'LICENSE_TYPE', 'C1', 'C1', NULL, 1, 1, '小型汽车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (31, 0, 'LICENSE_TYPE', 'C2', 'C2', NULL, 2, 1, '小型自动挡汽车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (32, 0, 'LICENSE_TYPE', 'B1', 'B1', NULL, 3, 1, '中型客车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (33, 0, 'LICENSE_TYPE', 'B2', 'B2', NULL, 4, 1, '大型货车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (34, 0, 'LICENSE_TYPE', 'A1', 'A1', NULL, 5, 1, '大型客车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (35, 0, 'LICENSE_TYPE', 'A2', 'A2', NULL, 6, 1, '牵引车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_dictionary` (`id`, `tenant_id`, `dict_type`, `dict_code`, `dict_label`, `dict_value`, `sort_order`, `status`, `remark`, `is_system`, `create_time`, `update_time`) VALUES (36, 0, 'LICENSE_TYPE', 'A3', 'A3', NULL, 7, 1, '城市公交车驾照', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
COMMIT;

-- ----------------------------
-- Table structure for sys_menu
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu`;
CREATE TABLE `sys_menu` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint NOT NULL COMMENT '租户ID (0表示系统级菜单模板)',
  `parent_id` bigint DEFAULT '0' COMMENT '父菜单ID (0表示顶级)',
  `module_key` varchar(50) DEFAULT NULL COMMENT '所属模块(collection/arrival/finance/data/settings)',
  `menu_code` varchar(50) NOT NULL COMMENT '菜单代码',
  `menu_name` varchar(50) NOT NULL COMMENT '菜单名称',
  `menu_path` varchar(200) DEFAULT NULL COMMENT '路由路径',
  `menu_icon` varchar(50) DEFAULT NULL COMMENT '图标',
  `menu_type` varchar(20) DEFAULT 'MENU' COMMENT '菜单类型(MODULE/MENU)',
  `sort_order` int DEFAULT '0',
  `status` tinyint DEFAULT '1' COMMENT '状态(1启用 0禁用)',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_tenant` (`tenant_id`),
  KEY `idx_parent` (`parent_id`),
  KEY `idx_module` (`module_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='菜单表';

-- ----------------------------
-- Records of sys_menu
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_menu_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_menu_permission`;
CREATE TABLE `sys_menu_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `menu_id` bigint NOT NULL COMMENT '菜单ID',
  `permission_id` bigint NOT NULL COMMENT '权限ID',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_menu_permission` (`menu_id`,`permission_id`),
  KEY `idx_menu` (`menu_id`),
  KEY `idx_permission` (`permission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='菜单权限关联表';

-- ----------------------------
-- Records of sys_menu_permission
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `sys_operation_log`;
CREATE TABLE `sys_operation_log` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户ID（0表示平台操作）',
  `user_id` bigint NOT NULL COMMENT '操作人ID',
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作人用户名',
  `operation_module` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作模块',
  `operation_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作类型（CREATE/UPDATE/DELETE/QUERY）',
  `operation_content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作内容描述',
  `ip_address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'IP地址',
  `user_agent` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '浏览器信息',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
  PRIMARY KEY (`id`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='操作日志表';

-- ----------------------------
-- Records of sys_operation_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_permission`;
CREATE TABLE `sys_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint NOT NULL COMMENT '租户ID (0表示平台级)',
  `permission_code` varchar(100) NOT NULL COMMENT '权限代码(如: order:create)',
  `permission_name` varchar(100) NOT NULL COMMENT '权限名称(如: 创建订单)',
  `permission_type` varchar(20) NOT NULL COMMENT '权限类型(MENU/BUTTON/DATA)',
  `parent_id` bigint DEFAULT '0' COMMENT '父权限ID（0表示顶级）',
  `route_path` varchar(200) DEFAULT NULL COMMENT '路由路径（菜单权限使用）',
  `component_path` varchar(200) DEFAULT NULL COMMENT '组件路径（菜单权限使用）',
  `icon` varchar(50) DEFAULT NULL COMMENT '图标',
  `resource_path` varchar(200) DEFAULT NULL COMMENT '资源路径(/tenant/order)',
  `description` varchar(500) DEFAULT NULL COMMENT '描述',
  `sort_order` int DEFAULT '0',
  `status` tinyint DEFAULT '1' COMMENT '状态(1启用 0禁用)',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_code` (`tenant_id`,`permission_code`),
  KEY `idx_tenant` (`tenant_id`),
  KEY `idx_type` (`permission_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='权限表';

-- ----------------------------
-- Records of sys_permission
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `role_code` varchar(50) NOT NULL COMMENT '角色代码(ADMIN/RECEIVER/INVOICER/FINANCE)',
  `role_name` varchar(50) NOT NULL COMMENT '角色名称(管理员/收货员/开票员/财务)',
  `role_type` int DEFAULT NULL COMMENT '角色类型：1-平台管理员,11-租户超管,21-站点管理员,31-普通操作员',
  `fixed_permission` tinyint(1) DEFAULT '0' COMMENT '是否固定权限（1-固定不可编辑，0-可编辑）',
  `permissions` text COMMENT '权限列表JSON数组',
  `description` varchar(500) DEFAULT NULL COMMENT '角色描述',
  `is_system` tinyint DEFAULT '0' COMMENT '是否系统预置：1-是（不可删除），0-否',
  `data_scope` varchar(20) DEFAULT 'SELF' COMMENT '数据范围(ALL/SELF/DEPT)',
  `status` tinyint DEFAULT '1' COMMENT '状态(1启用 0禁用)',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_code` (`tenant_id`,`role_code`),
  KEY `idx_tenant` (`tenant_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色表';

-- ----------------------------
-- Records of sys_role
-- ----------------------------
BEGIN;
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (1, 1, 'SUPER_ADMIN', '超级管理员', 11, 1, NULL, '顺丰公司超级管理员，拥有所有权限，可管理所有站点', 1, 'ALL', 1, '2025-11-14 16:46:17', '2025-11-15 17:56:55');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (2, 1, 'SITE_ADMIN', '站点管理员', 21, 0, '[\"w7n2p6f8\",\"y5b8n2t6\",\"kpywi5px\",\"e4t7g9l2\",\"x2h6w8n4\",\"s8j4p1w9\",\"i9w7b3h2\",\"w3c7v9k4\",\"l6f2h8m1\",\"z9x4q7p3\",\"j8n5r2w6\",\"b6k1m8f5\",\"v3h9c7x4\",\"f9k3p7q1\",\"v5l2m9c8\",\"a7z2q6n8\",\"m5k9r3f7\",\"t4x8c1l6\",\"u8g5p4j1\",\"o6v9k2x7\",\"n3f8z5w4\",\"q3v7t9b5\",\"c7m1q9r6\",\"c4h9k2m7\",\"z8f3x6w1\",\"b8f1p6j4\",\"v2h7m9c5\",\"page_c4h9k2m7\",\"page_z8f3x6w1\",\"page_y5b8n2t6\",\"page_kpywi5px\",\"page_e4t7g9l2\",\"page_x2h6w8n4\",\"page_s8j4p1w9\",\"page_i9w7b3h2\",\"page_c7m1q9r6\",\"page_r3t8q5l9\",\"page_l5k9w7x3\",\"z6t4q8r1\",\"x3w9l2k7\",\"l5k9w7x3\",\"y4n8g2z9\",\"k7w2f6b4\",\"p1m9x5v8\",\"q6j3h7c1\",\"r3t8q5l9\"]', '顺丰站点管理员，只能管理所属站点', 1, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-15 17:56:55');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (3, 1, 'DISPATCHER', '调度员', NULL, 0, '[\"w7n2p6f8\",\"y5b8n2t6\",\"kpywi5px\",\"e4t7g9l2\",\"x2h6w8n4\",\"s8j4p1w9\",\"i9w7b3h2\",\"w3c7v9k4\",\"l6f2h8m1\",\"z9x4q7p3\",\"j8n5r2w6\",\"b6k1m8f5\",\"v3h9c7x4\",\"f9k3p7q1\",\"v5l2m9c8\",\"a7z2q6n8\",\"m5k9r3f7\",\"t4x8c1l6\",\"u8g5p4j1\",\"o6v9k2x7\",\"n3f8z5w4\",\"q3v7t9b5\",\"c7m1q9r6\",\"page_y5b8n2t6\",\"page_kpywi5px\",\"page_e4t7g9l2\",\"page_x2h6w8n4\",\"page_s8j4p1w9\",\"page_i9w7b3h2\",\"page_c7m1q9r6\",\"page_r3t8q5l9\",\"page_d8l4h7p2\",\"page_l5k9w7x3\"]', '负责顺丰车辆调度和发车管理', 0, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-14 16:46:17');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (4, 1, 'FINANCE', '财务人员', NULL, 0, '[\"c4h9k2m7\",\"page_c4h9k2m7\"]', '负责顺丰运费结算和对账', 0, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-14 16:46:17');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (5, 2, 'SUPER_ADMIN', '超级管理员', 11, 1, NULL, '圆通公司超级管理员，拥有所有权限，可管理所有站点', 1, 'ALL', 1, '2025-11-14 16:46:17', '2025-11-15 17:56:55');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (6, 2, 'SITE_ADMIN', '站点管理员', 21, 0, NULL, '圆通站点管理员，只能管理所属站点', 1, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-15 17:56:55');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (7, 2, 'DISPATCHER', '调度员', NULL, 0, NULL, '负责圆通车辆调度和发车管理', 0, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-14 16:46:17');
INSERT INTO `sys_role` (`id`, `tenant_id`, `role_code`, `role_name`, `role_type`, `fixed_permission`, `permissions`, `description`, `is_system`, `data_scope`, `status`, `create_time`, `update_time`) VALUES (8, 2, 'FINANCE', '财务人员', NULL, 0, NULL, '负责圆通运费结算和对账', 0, 'SELF', 1, '2025-11-14 16:46:17', '2025-11-14 16:46:17');
COMMIT;

-- ----------------------------
-- Table structure for sys_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_permission`;
CREATE TABLE `sys_role_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `role_id` bigint NOT NULL COMMENT '角色ID',
  `permission_id` bigint NOT NULL COMMENT '权限ID',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_role_permission` (`role_id`,`permission_id`),
  KEY `idx_role` (`role_id`),
  KEY `idx_permission` (`permission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='角色权限关联表';

-- ----------------------------
-- Records of sys_role_permission
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_site
-- ----------------------------
DROP TABLE IF EXISTS `sys_site`;
CREATE TABLE `sys_site` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '所属公司ID',
  `site_code` varchar(50) NOT NULL COMMENT '站点代码',
  `site_name` varchar(100) NOT NULL COMMENT '站点名称',
  `address` varchar(255) DEFAULT NULL COMMENT '站点地址',
  `contact_name` varchar(50) DEFAULT NULL COMMENT '联系人',
  `contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
  `status` tinyint DEFAULT '1' COMMENT '状态：1启用 0禁用',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_site` (`tenant_id`,`site_code`),
  KEY `idx_tenant` (`tenant_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='站点表';

-- ----------------------------
-- Records of sys_site
-- ----------------------------
BEGIN;
INSERT INTO `sys_site` (`id`, `tenant_id`, `site_code`, `site_name`, `address`, `contact_name`, `contact_phone`, `status`, `create_time`, `update_time`) VALUES (1, 1, 'SZ001', '深圳福田站', '深圳市福田区华强北路1000号', '王站长', '0755-88888888', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_site` (`id`, `tenant_id`, `site_code`, `site_name`, `address`, `contact_name`, `contact_phone`, `status`, `create_time`, `update_time`) VALUES (2, 1, 'SZ002', '深圳南山站', '深圳市南山区科技园南区', '李站长', '0755-99999999', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_site` (`id`, `tenant_id`, `site_code`, `site_name`, `address`, `contact_name`, `contact_phone`, `status`, `create_time`, `update_time`) VALUES (3, 2, 'SH001', '上海徐汇站', '上海市徐汇区漕溪北路88号', '赵站长', '021-66666666', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `sys_site` (`id`, `tenant_id`, `site_code`, `site_name`, `address`, `contact_name`, `contact_phone`, `status`, `create_time`, `update_time`) VALUES (4, 2, 'SH002', '上海浦东站', '上海市浦东新区张江高科', '钱站长', '021-77777777', 1, '2025-11-14 15:51:10', '2025-11-14 15:51:10');
COMMIT;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户ID（0表示平台管理员）',
  `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '用户名',
  `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码（BCrypt加密）',
  `real_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '真实姓名',
  `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系电话',
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',
  `role_id` bigint DEFAULT NULL COMMENT '角色ID',
  `site_id` bigint DEFAULT NULL COMMENT '所属站点ID（超级管理员为NULL）',
  `is_super_admin` tinyint DEFAULT '0' COMMENT '是否超级管理员：1是 0否',
  `role` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '角色（PLATFORM_ADMIN/TENANT_ADMIN/TENANT_OPERATOR）',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态（1启用 0禁用）',
  `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `last_login_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '最后登录IP',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_username` (`tenant_id`,`username`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_role` (`role`),
  KEY `idx_site` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户表';

-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (1, 0, 'admin', '$2a$10$ABNxviNutREKJ1T.FXFsK.YIT3Nn1mMPnxURKxKmvMqVORI8LgoYa', '系统管理员', '13900000000', 'admin@logistics.com', NULL, NULL, 1, 'PLATFORM_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 15:56:32');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (2, 1, 'sf_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '顺丰管理员', '13800138001', 'admin@sf.com', NULL, 1, 0, 'SUPER_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:26:40');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (3, 1, 'sf_sz01_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '深圳福田站长', '13800138101', 'sz01@sf.com', NULL, 1, 0, 'SITE_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:18:44');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (4, 1, 'sf_sz02_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '深圳南山站长', '13800138102', 'sz02@sf.com', NULL, 2, 0, 'SITE_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:18:44');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (5, 2, 'yt_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '圆通管理员', '13800138002', 'admin@yt.com', NULL, NULL, 0, 'SUPER_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:26:40');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (6, 2, 'yt_sh01_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '上海徐汇站长', '13800138201', 'sh01@yt.com', NULL, 3, 0, 'SITE_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:18:44');
INSERT INTO `sys_user` (`id`, `tenant_id`, `username`, `password`, `real_name`, `phone`, `email`, `role_id`, `site_id`, `is_super_admin`, `role`, `status`, `last_login_time`, `last_login_ip`, `create_time`, `update_time`) VALUES (7, 2, 'yt_sh02_admin', '$2a$10$w/epTAWcEIVJw4167R1Gb.WnaZOdJ6W95KnpQzTf1QHRkNf0brQlm', '上海浦东站长', '13800138202', 'sh02@yt.com', NULL, 4, 0, 'SITE_ADMIN', 1, NULL, NULL, '2025-11-14 15:51:10', '2025-11-14 16:18:44');
COMMIT;

-- ----------------------------
-- Table structure for sys_user_permission
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_permission`;
CREATE TABLE `sys_user_permission` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `permission_id` bigint NOT NULL COMMENT '权限ID',
  `grant_type` tinyint NOT NULL COMMENT '授权类型(1授予 0撤销)',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_permission` (`user_id`,`permission_id`),
  KEY `idx_user` (`user_id`),
  KEY `idx_permission` (`permission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户特殊权限表';

-- ----------------------------
-- Records of sys_user_permission
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for sys_user_role
-- ----------------------------
DROP TABLE IF EXISTS `sys_user_role`;
CREATE TABLE `sys_user_role` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `role_id` bigint NOT NULL COMMENT '角色ID',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_role` (`user_id`,`role_id`),
  KEY `idx_user` (`user_id`),
  KEY `idx_role` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户角色关联表';

-- ----------------------------
-- Records of sys_user_role
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for transport_order
-- ----------------------------
DROP TABLE IF EXISTS `transport_order`;
CREATE TABLE `transport_order` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `site_id` bigint DEFAULT NULL COMMENT '所属站点',
  `departure_site_id` bigint DEFAULT NULL COMMENT '发货站点ID',
  `departure_site_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '发货站点名称（冗余）',
  `arrival_site_id` bigint DEFAULT NULL COMMENT '到货站点ID',
  `arrival_site_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '到货站点名称（冗余）',
  `order_no` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单编号',
  `goods_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '货物编码（如15-6）',
  `sender_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '发货联系人',
  `sender_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '发货电话',
  `sender_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '发货地址',
  `receiver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收货联系人',
  `receiver_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收货电话',
  `delivery_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT 'DELIVERY' COMMENT '配送方式：DELIVERY-送货上门, PICKUP-到站自提',
  `receiver_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '收货地址',
  `goods_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '货物名称',
  `goods_package` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '包装方式',
  `goods_pieces` int NOT NULL COMMENT '件数',
  `freight_amount` decimal(10,2) NOT NULL COMMENT '运费金额',
  `settlement_amount` decimal(10,2) DEFAULT '0.00' COMMENT '结算运费（给到货站点的结算金额）',
  `collection_amount` decimal(10,2) DEFAULT '0.00' COMMENT '代收款金额',
  `payment_method` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '付款方式（PREPAID/COLLECT）',
  `order_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单状态（UNASSIGNED/ASSIGNED/TRANSPORTING/DELIVERED/CANCELLED）',
  `driver_id` bigint DEFAULT NULL COMMENT '司机ID',
  `driver_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '司机姓名（冗余）',
  `driver_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '司机手机号',
  `vehicle_id` bigint DEFAULT NULL COMMENT '车辆ID',
  `vehicle_plate` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车牌号（冗余）',
  `loaded_at` datetime DEFAULT NULL COMMENT '装车时间',
  `assign_time` datetime DEFAULT NULL COMMENT '分配时间',
  `delivery_time` datetime DEFAULT NULL COMMENT '送达时间',
  `cancel_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '取消原因',
  `cancel_time` datetime DEFAULT NULL COMMENT '取消时间',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `issuer_id` bigint DEFAULT NULL COMMENT '开票员ID',
  `issuer_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '开票员姓名（冗余）',
  `create_by` bigint NOT NULL COMMENT '创建人ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新人ID',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `dispatched_at` datetime DEFAULT NULL COMMENT '发车时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_orderno` (`tenant_id`,`order_no`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_customer_id` (`tenant_id`),
  KEY `idx_order_status` (`tenant_id`,`order_status`),
  KEY `idx_driver_id` (`tenant_id`,`driver_id`),
  KEY `idx_create_time` (`tenant_id`,`create_time`),
  KEY `idx_site` (`site_id`),
  KEY `idx_goods_code` (`goods_code`),
  KEY `idx_departure_site` (`departure_site_id`),
  KEY `idx_arrival_site` (`arrival_site_id`),
  KEY `idx_issuer` (`issuer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='运输订单表（收货开票）';

-- ----------------------------
-- Records of transport_order
-- ----------------------------
BEGIN;
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (1, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115023752', '15-6', '李四', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '电子产品', NULL, 1, 8.00, 3.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 18:52:26', NULL, '2025-11-15 18:52:26', NULL);
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (2, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115386027', '15-6', '测试联系人', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '电子产品', NULL, 1, 3.00, 2.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 18:52:46', NULL, '2025-11-15 18:52:46', NULL);
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (3, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115590847', '15-2', '李四', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '测试', NULL, 1, 6.00, 4.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 18:53:06', NULL, '2025-11-15 18:53:06', NULL);
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (4, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115928908', '14-9', '测试联系人', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '电子产品', NULL, 1, 7.00, 6.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 18:53:36', NULL, '2025-11-15 18:53:36', NULL);
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (5, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115682255', '14-9', '测试联系人', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '电子产品', NULL, 1, 1.00, 0.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 18:53:57', NULL, '2025-11-15 18:53:57', NULL);
INSERT INTO `transport_order` (`id`, `tenant_id`, `site_id`, `departure_site_id`, `departure_site_name`, `arrival_site_id`, `arrival_site_name`, `order_no`, `goods_code`, `sender_name`, `sender_phone`, `sender_address`, `receiver_name`, `receiver_phone`, `delivery_type`, `receiver_address`, `goods_name`, `goods_package`, `goods_pieces`, `freight_amount`, `settlement_amount`, `collection_amount`, `payment_method`, `order_status`, `driver_id`, `driver_name`, `driver_phone`, `vehicle_id`, `vehicle_plate`, `loaded_at`, `assign_time`, `delivery_time`, `cancel_reason`, `cancel_time`, `remark`, `issuer_id`, `issuer_name`, `create_by`, `create_time`, `update_by`, `update_time`, `dispatched_at`) VALUES (6, 1, 1, 1, '深圳福田站', 2, '深圳南山站', 'TS20251115220550', '15-47', '测试联系人', '15376001504', NULL, '彭奥翔', '15376001504', 'DELIVERY', '山东省青岛市李沧区青岛百杉科技有限公司', '电子产品', NULL, 1, 6.00, 4.00, 0.00, 'PREPAID', 'RECEIVED', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', 2, '顺丰管理员', 2, '2025-11-15 19:05:08', NULL, '2025-11-15 19:05:08', NULL);
COMMIT;

-- ----------------------------
-- Table structure for vehicle
-- ----------------------------
DROP TABLE IF EXISTS `vehicle`;
CREATE TABLE `vehicle` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tenant_id` bigint NOT NULL COMMENT '租户ID',
  `site_id` bigint DEFAULT NULL COMMENT '所属站点',
  `plate_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车牌号',
  `vehicle_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车辆类型（VAN/FLATBED/REFRIGERATED/OTHER）',
  `brand_model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '品牌型号',
  `load_capacity` decimal(10,2) DEFAULT NULL COMMENT '载重（吨）',
  `volume_capacity` decimal(10,2) DEFAULT NULL COMMENT '容积（立方米）',
  `purchase_date` date DEFAULT NULL COMMENT '购买日期',
  `insurance_expire_date` date DEFAULT NULL COMMENT '保险到期日期',
  `inspection_expire_date` date DEFAULT NULL COMMENT '年检到期日期',
  `vehicle_status` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车辆状态（AVAILABLE/IN_USE/MAINTENANCE/DISABLED）',
  `vehicle_source` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'COMPANY' COMMENT '车辆来源（COMPANY/TEMP）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `owner_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车主姓名（必填）',
  `owner_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '车主联系电话（必填）',
  `owner_id_card` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车主身份证号',
  `owner_license_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车主驾驶证号',
  `owner_license_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车主驾驶证类型（A1/A2/B1/B2/C1等）',
  `owner_license_expire_date` date DEFAULT NULL COMMENT '车主驾驶证到期日期',
  `owner_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '车主地址',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_tenant_plate` (`tenant_id`,`plate_number`),
  KEY `idx_tenant_id` (`tenant_id`),
  KEY `idx_vehicle_status` (`tenant_id`,`vehicle_status`),
  KEY `idx_site` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='车辆表';

-- ----------------------------
-- Records of vehicle
-- ----------------------------
BEGIN;
INSERT INTO `vehicle` (`id`, `tenant_id`, `site_id`, `plate_number`, `vehicle_type`, `brand_model`, `load_capacity`, `volume_capacity`, `purchase_date`, `insurance_expire_date`, `inspection_expire_date`, `vehicle_status`, `vehicle_source`, `remark`, `owner_name`, `owner_phone`, `owner_id_card`, `owner_license_number`, `owner_license_type`, `owner_license_expire_date`, `owner_address`, `create_time`, `update_time`) VALUES (1, 1, NULL, '粤B12345', 'VAN', '福田欧马可', 3.50, 15.00, '2023-01-15', '2025-01-15', '2025-12-31', 'AVAILABLE', 'COMPANY', '3.5吨厢式货车', '王师傅', '13900001001', '440300199001011234', 'C1E1234567890', 'C1', '2028-01-15', '深圳市福田区', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `vehicle` (`id`, `tenant_id`, `site_id`, `plate_number`, `vehicle_type`, `brand_model`, `load_capacity`, `volume_capacity`, `purchase_date`, `insurance_expire_date`, `inspection_expire_date`, `vehicle_status`, `vehicle_source`, `remark`, `owner_name`, `owner_phone`, `owner_id_card`, `owner_license_number`, `owner_license_type`, `owner_license_expire_date`, `owner_address`, `create_time`, `update_time`) VALUES (2, 1, NULL, '粤B67890', 'FLATBED', '东风天锦', 8.00, 35.00, '2022-06-20', '2025-06-20', '2025-08-30', 'AVAILABLE', 'COMPANY', '8吨平板车', '李师傅', '13900001002', '440300199002021234', 'B2F2345678901', 'B2', '2027-06-20', '深圳市南山区', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `vehicle` (`id`, `tenant_id`, `site_id`, `plate_number`, `vehicle_type`, `brand_model`, `load_capacity`, `volume_capacity`, `purchase_date`, `insurance_expire_date`, `inspection_expire_date`, `vehicle_status`, `vehicle_source`, `remark`, `owner_name`, `owner_phone`, `owner_id_card`, `owner_license_number`, `owner_license_type`, `owner_license_expire_date`, `owner_address`, `create_time`, `update_time`) VALUES (3, 2, NULL, '沪A11111', 'VAN', '江淮骏铃', 4.20, 18.00, '2023-03-10', '2025-03-10', '2025-10-15', 'AVAILABLE', 'COMPANY', '4.2吨厢车', '张师傅', '13900002001', '310115199003031234', 'C1G3456789012', 'C1', '2028-03-10', '上海市徐汇区', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
INSERT INTO `vehicle` (`id`, `tenant_id`, `site_id`, `plate_number`, `vehicle_type`, `brand_model`, `load_capacity`, `volume_capacity`, `purchase_date`, `insurance_expire_date`, `inspection_expire_date`, `vehicle_status`, `vehicle_source`, `remark`, `owner_name`, `owner_phone`, `owner_id_card`, `owner_license_number`, `owner_license_type`, `owner_license_expire_date`, `owner_address`, `create_time`, `update_time`) VALUES (4, 2, NULL, '沪A22222', 'VAN', '解放J6F', 2.50, 12.00, '2023-08-15', '2025-08-15', '2025-11-30', 'AVAILABLE', 'COMPANY', '2.5吨小厢车', '赵师傅', '13900003001', '310115199004041234', 'C1H4567890123', 'C1', '2028-08-15', '上海市浦东区', '2025-11-14 15:51:10', '2025-11-14 15:51:10');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
